$(function () {
    $.get("/templat/header.html", function (data) {
        console.log(data);
        $("#header").html(data)


        $.get("/lession05/checkLogin", function (data) {
            if (data.error) {
                localStorage.removeItem("username")
            }

            let username = localStorage.getItem("username")
            if (username) {
                $(".nav-list2").html(`
                    <a>${username}</a>&emsp;&emsp;&emsp;<a class="exit">退出</a>
                `)
            }
        })
    })

    $("#header").on("click", ".exit", function () {
        
        $.get("/lession05/exit",function(data) {
            console.log(data)
            if(!data.error) {
                localStorage.removeItem("username")
                location.reload()
            }
        })
        
    })





})